package top.leyi.ServiceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.leyi.IService.ICommService;
import top.leyi.entity.Commodity;
import top.leyi.entity.SQLUtil;
import top.leyi.entity.user.User;
import top.leyi.mapper.CommMapper;

import java.util.List;

/**
 * @descripe 商品service
 * @author allen
 * @date 2019/6/16
 */
@Service
public class CommServiceImpl  implements ICommService {
    @Autowired
    CommMapper commMapper;
    @Override
    public List<Commodity> getAllCommdities(int page, String key) {
        SQLUtil util = new SQLUtil();
        util.setLimit(LIMIT);
        util.setOffset(LIMIT*(page - 1));
        util.setKey(key);
        return commMapper.fuzzyQueryAllCommdity(util);
    }

    @Override
    public void addOneCommo(Commodity commodity, User user) {
        commMapper.addOneCommodity(commodity);
    }


}
